cphsoc_path_info <- function(path)
{
  basename <- basename(path)
  dir <- dirname(path)
  LONG_FILENAME_WARN <- FALSE
  n <- nchar(basename)
  if(n>255) LONG_FILENAME_WARN <- TRUE
  if(n>1000) stop(paste('Very long filename: ',n,' characters.',sep=''))
  dotpos <- gregexpr('\\.',basename)[[1]]

  HIDDEN_FILE_WARN <- FALSE
  if (1 %in% dotpos) HIDDEN_FILE_WARN <- TRUE
  
  m <- max(dotpos)
  if(m>0)
  {
    file_ext <- substr(basename,m+1,n)
    file_dot_ext <- substr(basename,m,n)
    filename <- substr(basename,1,m-1)
    list(dirname=dir,basename=basename,filename=filename,extension=file_ext,dot_extension=file_dot_ext)
  }
  else
  {
    list(dirname=dir,basename=basename,filename=basename,extension="",dot_extension="")
  }
}
